package com.ipharma.gui;

import java.util.Vector;

import com.ipharma.application.services.transaccion.TransactionRecycle;
import com.ipharma.dto.Product;

/**
 * A Swing-based panel class.
 * <P>
 * @author JorgE.H
 */
public class GUITransactionRecycle extends GUITransaction
{
  /**
   * Attributes
   */

  /**
   * Panel
   */

  /**
   * Constructs a new instance.
   */
  public GUITransactionRecycle( GUIOperation pContainer )
  {
    super( pContainer );
  }

  /**
   * Performs several transactions form a vector of products.
   * @param pProducts the products vector
   */
  public void addProducts( Vector pProducts )
  {
    if ( selectedProducts == null )
      selectedProducts = new TransactionRecycle( theSess );
    for ( int i = 0; i < pProducts.size(); i++ )
    {
      Product l_prod = (Product) pProducts.get( i );
      if ( l_prod.isAvailable() && l_prod.getQuantity() > 0 )
      {
        selectedProducts.addItem( l_prod );

        jDetailArea.setText( jDetailArea.getText() + l_prod.getDescription() + " - "
            + l_prod.getQuantity() + "\n" );
      }
    }
  }
}